﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Kiss.WinForm.OrderService;

namespace Kiss.WinForm
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void getButton_Click(object sender, EventArgs e)
        {
            OrderServiceClient service = new OrderServiceClient();
            Customer[] customers = service.GetCustomersByCity(cityTextBox.Text);
            dataGrid.DataSource = customers;
        }

        private void updateButton_Click(object sender, EventArgs e)
        {
            OrderServiceClient service = new OrderServiceClient();
            Customer customer = ((Customer[])dataGrid.DataSource)[dataGrid.CurrentRow.Index];
            if(!customer.City.EndsWith("X"))
                customer.City = customer.City + "X";
            else
                customer.City = customer.City.Remove(customer.City.Length - 1);
            service.UpdateCustomer(customer);
        }
    }
}
